$(function() {
    $("#login-button").click(function() {
        console.log(1);
        if ($("#uname").val() == "" || $("#password").val() == "") {
            console.log($("#uname").val(), $("#password").val());
            alert("用户名或密码不能为空");
        } else {
            $.get(
                "http://jx.xuzhixiang.top/ap/api/login.php", {
                    username: $("#uname").val(),
                    password: $("#password").val(),
                },
                function(data) {
                    console.log(data);
                    if (data["code"] == 0) {
                        alert(data["msg"]);
                    } else {
                        location.href = "./index.html";
                    }
                }
            );
        }
        return false;
    });
});